<?php
/**
 * Edit blog form
 *
 * @package Blog
 */

$blog = get_entity($vars['guid']);
$vars['entity'] = $blog;

$draft_warning = $vars['draft_warning'];
if ($draft_warning) {
	$draft_warning = '<span class="mbm elgg-text-help">' . $draft_warning . '</span>';
}

$action_buttons = '';
$delete_link = '';
$preview_button = '';

if ($vars['guid']) {
	// add a delete button if editing
	$delete_url = "action/blog/delete?guid={$vars['guid']}";
	$delete_link = elgg_view('output/confirmlink', array(
		'href' => $delete_url,
		'text' => elgg_echo('delete'),
		'class' => 'elgg-button elgg-button-delete float-alt'
	));
}

$exchangeProductName_input = elgg_view('input/text',array('name' => 'exchangeProductName','class' => 'elgg-autofocus th_input_text',));
$exchangeProductName_label = elgg_echo('name:ExchangeProduct');

$receiveProductName_input = elgg_view('input/text',array('name' => 'receiveProductName','class' => 'th_input_text'));
$receiveProductName_label = elgg_echo('name:ReceiveProduct');

$exchangeProductDescription_input = elgg_view('input/longtext',array('name' => 'exchangeProductDescription','class' => 'th_textarea',));
$exchangeProductDescription_label = elgg_echo('description:ExchangeProduct');

$receiveProductDescription_input = elgg_view('input/longtext',array('name' => 'receiveProductDescription','class' => 'th_textarea',));
$receiveProductDescription_label = elgg_echo('description:ReceiveProduct');
$phone=elgg_echo('category:phone');
$computer =elgg_echo('category:computer');
$ornamental = elgg_echo('category:ornamental');
$other= elgg_echo('category:other');
$codes = array(
'phone',
'computer',
'ornamental',
'other',
);
$optionsCategory = array();
foreach ($codes as $code) {
$optionsCategory[$code] = elgg_echo("category:$code");
}
//$optionsCategory = array($phone,$computer,$ornamental ,$other );
//$optionsCategory = array("phone","computer","ornamental" ,"other" );
$exchangeProductCategory_input = elgg_view('input/dropdown',array('name' => 'exchangeProductCategory', 'options'=> $optionsCategory));
$receiveProductCategory_input = elgg_view('input/dropdown',array('name' => 'receiveProductCategory', 'options'=> $optionsCategory,));
$ProductCategory_label = elgg_echo('product:category');

$exchangeProductPrice_label = elgg_echo('price:ExchangeProduct');
$exchangeProductPrice_input = elgg_view('input/text',array('name' => 'exchangeProductPrice','class' => 'th_input_text',));

$optionsMoneyType = array("VND", "USD");
$exchangeMoneyType_input = elgg_view('input/dropdown',array('name' => 'exchangeMoneyType', 'options'=> $optionsMoneyType,));
$exchangeMoneyType_label = elgg_echo('money:type');

$exchangeProductImage_label = elgg_echo('image:exchangeProduct');
$exchangeProductImage_input = elgg_view('input/file',array('name' => 'exchangeProductImage',));
$save_button = elgg_view('input/submit', array(
	'value' => elgg_echo('save'),
	'name' => 'save',
));
$action_buttons = $save_button . $preview_button . $delete_link;

$title_label = elgg_echo('title');
$title_input = elgg_view('input/text', array(
	'name' => 'title',
	'id' => 'blog_title',
	'value' => $vars['title']
));

$excerpt_label = elgg_echo('blog:excerpt');
$excerpt_input = elgg_view('input/text', array(
	'name' => 'excerpt',
	'id' => 'blog_excerpt',
	'value' => _elgg_html_decode($vars['excerpt'])
));

$body_label = elgg_echo('blog:body');
$body_input = elgg_view('input/longtext', array(
	'name' => 'description',
	'id' => 'blog_description',
	'value' => $vars['description']
));

$save_status = elgg_echo('blog:save_status');
if ($vars['guid']) {
	$entity = get_entity($vars['guid']);
	$saved = date('F j, Y @ H:i', $entity->time_created);
} else {
	$saved = elgg_echo('blog:never');
}

$status_label = elgg_echo('blog:status');
$status_input = elgg_view('input/dropdown', array(
	'name' => 'status',
	'id' => 'blog_status',
	'value' => $vars['status'],
	'options_values' => array(
		'draft' => elgg_echo('blog:status:draft'),
		'published' => elgg_echo('blog:status:published')
	)
));

$comments_label = elgg_echo('comments');
$comments_input = elgg_view('input/dropdown', array(
	'name' => 'comments_on',
	'id' => 'blog_comments_on',
	'value' => $vars['comments_on'],
	'options_values' => array('On' => elgg_echo('on'), 'Off' => elgg_echo('off'))
));

$tags_label = elgg_echo('tags');
$tags_input = elgg_view('input/tags', array(
	'name' => 'tags',
	'id' => 'blog_tags',
	'value' => $vars['tags']
));

$access_label = elgg_echo('access');
$access_input = elgg_view('input/access', array(
	'name' => 'access_id',
	'id' => 'blog_access_id',
	'value' => $vars['access_id']
));

$categories_input = elgg_view('input/categories', $vars);

// hidden inputs
$container_guid_input = elgg_view('input/hidden', array('name' => 'container_guid', 'value' => elgg_get_page_owner_guid()));
$guid_input = elgg_view('input/hidden', array('name' => 'guid', 'value' => $vars['guid']));


echo <<<___HTML

$draft_warning
<p class="th_title">San Pham Muon Doi</p>

<div class="th_element"> 
	<p class="th_input_label">$exchangeProductName_label</p> $exchangeProductName_input
</div>
 
<div class="th_element"> 
	<p class="th_input_label">$ProductCategory_label</p> $exchangeProductCategory_input
</div>

<div class="th_element"> 
	<p class="th_input_label">$exchangeProductPrice_label</p>$exchangeProductPrice_input
</div>

<div class="th_element"> 
	<p class="th_input_label">$exchangeMoneyType_label</p>$exchangeMoneyType_input
</div>

<div class="th_element"> 
	<p class="th_input_label">$exchangeProductDescription_label</p><br />$exchangeProductDescription_input
</div>

<div class="th_imagebox">
	$exchangeProductImage_input
</div>


<p class="th_title">San Pham Muon Nhan</p>

<div class="th_element"> 
	<p class="th_input_label">$receiveProductName_label</p>$receiveProductName_input
</div>

<div class="th_element"> 
	<p class="th_input_label">$ProductCategory_label</p>$receiveProductCategory_input
</div>

<div class="th_element"> 
	<p class="th_input_label">$receiveProductDescription_label</p>$receiveProductDescription_input
</div>

<div class="th_element"> 
	<label class="th_input_label" for="blog_comments_on">$comments_label</label>$comments_input
</div>

<div class="th_element"> 
	<label class="th_input_label" for="blog_access_id">$access_label</label>$access_input
</div>

<div class="th_element"> 
	<label class="th_input_label" for="blog_status">$status_label</label>$status_input
</div>

<div class="elgg-foot">
	<div class="elgg-subtext mbm">
	$save_status <span class="blog-save-status-time">$saved</span>
	</div>

	$guid_input
	$container_guid_input

	$action_buttons
</div>

___HTML;
